﻿using System;
using Beaker;

namespace OpenCube.Nbt.Mapping.Converters
{
	[CLSCompliant(false)]
	public sealed class BooleanConverter
		: NbtSimpleTypeConverter<bool, sbyte>
	{
		protected override bool ConvertToModelValue(sbyte nbtValue)
		{
			return nbtValue == 1;
		}

		protected override Maybe<sbyte> ConvertToNbtValue(bool modelValue)
		{
			return modelValue ? (sbyte)1 : (sbyte)0;
		}
	}
}
